import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '风险事件名称',
    align:"center",
    dataIndex: 'riskEventName'
   },
   {
    title: '风险分析装置',
    align:"center",
    dataIndex: 'riskDeviceId_dictText'
   },
   {
    title: '风险分析单元',
    align:"center",
    dataIndex: 'riskUnitId_dictText'
   },
   {
    title: '重大危险源级别',
    align:"center",
    dataIndex: 'seriousHazard_dictText'
   },
   {
    title: '责任部门',
    align:"center",
    dataIndex: 'hazardDep_dictText'
   },
   {
    title: '责任人',
    align:"center",
    dataIndex: 'hazardLiablePerson_dictText'
   },
   // {
   //  title: '删除标志',
   //  align:"center",
   //  dataIndex: 'deleted_dictText'
   // },
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "风险事件名称",
      field: "riskEventName",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "风险分析装置",
      field: "riskDeviceId",
      component: 'JSearchSelect',
      componentProps:{
         dict:"tb_base_risk_device,name,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "风险分析单元",
      field: "riskUnitId",
      component: 'JSearchSelect',
      componentProps:{
         dict:"tb_base_risk_unit,risk_unit_name,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "重大危险源级别",
      field: "seriousHazard",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"serious_hazard"
      },
      //colProps: {span: 6},
 	},
	{
      label: "责任部门",
      field: "hazardDep",
      component: 'JSelectDept',
      //colProps: {span: 6},
 	},
	{
      label: "责任人",
      field: "hazardLiablePerson",
      component: 'JSelectUser',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '风险事件名称',
    field: 'riskEventName',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入风险事件名称!'},
          ];
     },
  },
  {
    label: '风险分析装置',
    field: 'riskDeviceId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"tb_base_risk_device,name,id"
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入风险分析装置!'},
          ];
     },
  },
  {
    label: '风险分析单元',
    field: 'riskUnitId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"tb_base_risk_unit,risk_unit_name,id"
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入风险分析单元!'},
          ];
     },
  },
  {
    label: '重大危险源级别',
    field: 'seriousHazard',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"serious_hazard"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入重大危险源级别!'},
          ];
     },
  },
  {
    label: '责任部门',
    field: 'hazardDep',
     component: 'JSelectDept',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入责任部门!'},
          ];
     },
  },
  {
    label: '责任人',
    field: 'hazardLiablePerson',
    component: 'JSelectUser',
    componentProps:{
        labelKey:'realname',
     },
  },
  {
    label: '删除标志',
    field: 'deleted',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yn"
     },
    dynamicDisabled:true
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const tbBaseControlMeasuresColumns: JVxeColumn[] = [
    {
      title: '管控方式',
      key: 'dataSrc',
      type: JVxeTypes.select,
      options:[],
      dictCode:"data_src",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '管控措施描述',
      key: 'riskMeasureDesc',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '隐患排查内容',
      key: 'troubleshootContent',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '管控措施1',
      key: 'classify1',
      type: JVxeTypes.select,
      options:[],
      dictCode:"classify1",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
      linkageKey: 'classify2',//联动字段配置
    },
    {
      title: '管控措施2',
      key: 'classify2',
      type: JVxeTypes.select,
      options:[],
      dictCode:"classify2",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '管控措施3',
      key: 'classify3',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    // {
    //   title: '删除标志',
    //   key: 'deleted',
    //   type: JVxeTypes.select,
    //   options:[],
    //   dictCode:"yn",
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '人员岗位',
    //   key: 'personnelPosition',
    //   type: JVxeTypes.input,
    //   options:[],
    //   dictCode:"",
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '人员岗位',
      key: 'personnelPosition',
      width: 180,
      type: JVxeTypes.input,
      defaultValue: '',
      placeholder: '请输入${title}',
      validateRules: [{ required: true, message: '${title}不能为空' }],
    },
    {
      title: '排查周期',
      key: 'period',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '周期单位',
      key: 'periodUnit',
      type: JVxeTypes.select,
      options:[],
      dictCode:"period_type",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '数据来源',
      key: 'source',
      type: JVxeTypes.select,
      options:[],
      dictCode:"source_type",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  createTime: {title: '创建日期',order: 0,view: 'datetime', type: 'string',},
  riskEventName: {title: '风险事件名称',order: 1,view: 'textarea', type: 'string',},
  riskDeviceId: {title: '风险分析装置',order: 2,view: 'sel_search', type: 'string',dictTable: "tb_base_risk_device", dictCode: 'id', dictText: 'name',},
  riskUnitId: {title: '风险分析单元',order: 3,view: 'sel_search', type: 'string',dictTable: "tb_base_risk_unit", dictCode: 'id', dictText: 'risk_unit_name',},
  seriousHazard: {title: '重大危险源级别',order: 4,view: 'list', type: 'string',dictCode: 'serious_hazard',},
  hazardDep: {title: '责任部门',order: 5,view: 'sel_depart', type: 'string',},
  hazardLiablePerson: {title: '责任人',order: 6,view: 'sel_user', type: 'string',},
  deleted: {title: '删除标志',order: 7,view: 'radio', type: 'string',},
  //子表高级查询
  tbBaseControlMeasures: {
    title: '管控措施信息',
    view: 'table',
    fields: {
        dataSrc: {title: '管控方式',order: 0,view: 'list', type: 'string',dictCode: 'data_src',},
        riskMeasureDesc: {title: '管控措施描述',order: 1,view: 'textarea', type: 'string',},
        troubleshootContent: {title: '隐患排查内容',order: 2,view: 'textarea', type: 'string',},
        classify1: {title: '管控措施1',order: 3,view: 'list', type: 'string',dictCode: 'classify1',},
        classify2: {title: '管控措施2',order: 4,view: 'list', type: 'string',dictCode: 'classify2',},
        classify3: {title: '管控措施3',order: 5,view: 'textarea', type: 'string',},
        deleted: {title: '删除标志',order: 6,view: 'radio', type: 'string',},
        personnelPosition: {title: '人员岗位',order: 7,view: 'list', type: 'string',},
        period: {title: '排查周期',order: 8,view: 'number', type: 'number',},
        periodUnit: {title: '周期单位',order: 9,view: 'list', type: 'string',dictCode: 'period_type',},
        source: {title: '数据来源',order: 10,view: 'list', type: 'string',dictCode: 'source_type',},
    }
  },
};
